package com.bolt.core.view.components;

import com.bolt.common.utils.StrUtil;

import java.util.HashMap;
import java.util.Map;


public class PageView extends ComponentsBase {
	public static final String TEMPLATE = "page.ftl";
	private String template;
	private Map<String,Form> forms ;
	
	public PageView() {
    	super();
    	forms = new HashMap<>();
	}

	@Override
    protected String getDefaultTemplate(){
		if(StrUtil.isNotEmpty(template)){
			return template;
		}
		return TEMPLATE;
	}
	
	public void addForm(Form form){
		forms.put(form.getId(), form);
	}
	
	
	public Form getForm(String formId){
		return forms.get(formId);
	}
	
	public void addAllForms(Map<String,Form> forms){
		for(String formId : forms.keySet()){
			Form newForm = forms.get(formId);
			this.getAllForms().put(formId, newForm);
		}
	}
	
	public Map<String,Form> getAllForms(){
		return forms;
	}
	
	
}
